-
Notifications
You must be signed in to change notification settings - Fork 3k
[Monitor-OpenTelemetry-Exporter] Add 15 Second Warmup for Long-Interval Statsbeat #41229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Monitor-OpenTelemetry-Exporter] Add 15 Second Warmup for Long-Interval Statsbeat #41229
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a 15‑second warmup delay to prevent immediate export of long‑interval Statsbeat metrics upon client startup.
- Updated tests to use time mocking to simulate metrics collection before and after the delay
- Added startup delay logic in _statsbeat_metrics and scheduled a delayed export in _statsbeat using a Timer
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/statsbeat/test_statsbeat.py | Updated tests to validate that metrics are not emitted before the 15‑second delay |
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_statsbeat_metrics.py | Added delay logic based on startup time for both feature and attach metrics |
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_statsbeat.py | Introduced a Timer to force a second export after 15 seconds |
...-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_statsbeat.py
Outdated
Show resolved
Hide resolved
...-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_statsbeat_metrics.py
Outdated
Show resolved
Hide resolved
…/opentelemetry/exporter/statsbeat/_statsbeat_metrics.py Co-authored-by: Copilot <[email protected]>
...-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_statsbeat.py
Outdated
Show resolved
Hide resolved
...-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_statsbeat.py
Show resolved
Hide resolved
...-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_statsbeat.py
Outdated
Show resolved
Hide resolved
...-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_statsbeat.py
Outdated
Show resolved
Hide resolved
...-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_statsbeat_metrics.py
Outdated
Show resolved
Hide resolved
@@ -99,6 +99,7 @@ | |||
_DEFAULT_EU_STATS_CONNECTION_STRING = "InstrumentationKey=7dc56bab-3c0c-4e9f-9ebb-d1acadee8d0f;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/" | |||
_DEFAULT_STATS_SHORT_EXPORT_INTERVAL = 900 # 15 minutes | |||
_DEFAULT_STATS_LONG_EXPORT_INTERVAL = 86400 # 24 hours | |||
_INITIAL_DELAY_SECONDS = 60.0 # 15 second delay for the first long-interval export |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 60s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing value - cleaning.
@@ -36,15 +70,17 @@ def collect_statsbeat_metrics(exporter) -> None: | |||
) | |||
reader = PeriodicExportingMetricReader( | |||
statsbeat_exporter, | |||
export_interval_millis=_get_stats_short_export_interval() * 1000, # 15m by default | |||
export_interval_millis=_get_stats_short_export_interval() * 1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: There's still some of these random refactors and new variables?
@@ -138,6 +140,9 @@ def __init__( | |||
_FEATURE_METRIC_NAME[0]: sys.maxsize, | |||
} | |||
self._long_interval_lock = threading.Lock() | |||
# Add startup timestamp and delay for initial statsbeat metrics | |||
self._startup_time = time.time() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these needed?
Description
Adds a 15 second delay for Long-Interval Statsbeat collection such that it is not exported immediately upon startup of the client application.
If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines